/**
 * 我的服务
 */
$(function() {
		loadmyservice();
});

function loadmyservice(){
//	var param= {"userid": USERID};  &pageSize=3&pageNo=1 分页参数
	var param= {"userid": USERID,"typeOrder":1};
	userCenterModule.queryMyService(param,loadhtml);
	var param= {"userid": USERID,"typeOrder":2};
	userCenterModule.queryMyService(param,loadhtml1);
	var param= {"userid": USERID,"typeOrder":3};
	userCenterModule.queryMyService(param,loadhtml2);
}
function loadhtml(json){
	var showhtml1="";
	console.log(json.data)
	
	if(json.data){
		for(var i=0;i<json.data.length;i++){
				item=json.data[i];
				showhtml1+='<li><div class="question">';
				showhtml1+='<div class="name">';
				if(typeof(item.doctorid) == "undefined"){
					item.doctorid ='';
					item.realname = "暂无医生";
					item.deptName = "暂无部门";
				}
				showhtml1+='<font class="font4">'+item.realname+'</font>';
					if(item.qstatus==2){
						if(item.iscommented ==0){
							showhtml1+=	'<a href="../service/evaluate-doctor.html?doctorid='+item.doctorid+'&serviceid='+item.questionid+'&type=1" class="color_blue">待评价</a>';
						}else{
							showhtml1+=	'<span href="javascript:;"  class="color_blue">已完成</span>';
						}
					}else{
						if(item.qstatus==1){
							showhtml1+=	'<span href="javascript:;"  class="color_blue">已领取</span>';
						}else if(item.qstatus==0){
							showhtml1+=	'<span href="javascript:;"  class="color_blue">未领取</span>';
						}else if(item.qstatus==3){
							showhtml1+=	'<span href="javascript:;"  class="color_blue">超时关闭</span>';
						}else{
							showhtml1+=	'<span href="javascript:;"  class="color_blue">已完成</span>';
						}
					}
				showhtml1+='</div>';
				showhtml1+='<div class="time">';
				showhtml1+=item.createtime;
				showhtml1+='<span>|</span>'+item.deptName;
				showhtml1+=	'</div><div class="text font3">';
				showhtml1+=item.questionbody;
				showhtml1+='</div>';
				if(item.avatar){
					showhtml1+=	'<img src="'+item.avatar+'" />';
				}else{
					showhtml1+=	"<img src='../../images/default-doctor.png'/>";
				}
				showhtml1+=	'</li>';
		}
	}else{
		showhtml1='<div class="prescription-consultationBox"><div><img src="../../images/cf1_03.png" /><p class="font3"style="color:#999">您暂时没有要评价的订单</p></div></div>';
	}
	$($(".servise-content .servise-list")[0]).html(showhtml1);
}
function loadhtml1(json){
	var showhtml1="";
	console.log(json.data)
	if(json.data){
		for(var i=0;i<json.data.length;i++){
				item=json.data[i];
				showhtml1+='<li><div class="question">';
				showhtml1+='<div class="name">';
				showhtml1+='<font class="font4">'+item.realname+'</font>';
				if(item.status==0)
					showhtml1+=	'<span class="color_blue">未支付</span>';
				if(item.status==1)
					showhtml1+=	'<span class="color_blue">进行中</span>';
				if(item.status==2)
					showhtml1+=	'<span class="color_blue">已支付</span>';
				if(item.status==3)
					if(item.isCommented ==0){ 
						
					showhtml1+=	'<a href="../service/evaluate-doctor.html?doctorid='+item.doctorid+'&serviceid='+item.id+'&type=2" class="color_blue">待评价</a>';
					
					
					}else{
						showhtml1+=	'<span href="javascript:;"  class="color_blue">已评价</span>';
					}
				if(item.status==4)
					showhtml1+=	'<span href="javascript:;"  class="color_blue">已评价</span>';
				showhtml1+='</div>';
				showhtml1+='<div class="time">';
				showhtml1+=item.createtime;
				showhtml1+='<span>|</span>'+item.deptName;
				showhtml1+=	'</div><div class="text font3">';
				showhtml1+=item.questionbody;
				showhtml1+='</div>';
				if(item.avatar){
					showhtml1+=	'<img src="'+item.avatar+'" />';
				}else{
					showhtml1+=	"<img src='../../images/default-doctor.png'/>";
				}
				showhtml1+=	'</li>';
		}
	}else{
		showhtml1='<div class="prescription-consultationBox"><div><img src="../../images/cf1_03.png" /><p class="font3" style="color:#999">您暂时没有要评价的订单</p></div></div>';
	}
	$($(".servise-content .servise-list")[1]).html(showhtml1);
}
function loadhtml2(json){
	var showhtml1="";
	console.log(json.data);
	if(json.data){
		
		for(var i=0;i<json.data.length;i++){
				item=json.data[i];
				showhtml1+='<li><div class="question">';
				showhtml1+='<div class="name">';
				showhtml1+='<font class="font4">'+item.realname+'</font>';			
				if(item.status==0){
					var currentTime=new Date().getTime(); //当前时间
					var bespeakTime = Date.parse(new Date(item.serviceTime));//预约时间
					var timeDiff = bespeakTime - currentTime;
					
					console.log(timeDiff);
					if(timeDiff>0){
						showhtml1+= '<a href="../order/order-pay.html?orderType=2&orderid='+item.id+'&type=3"  class="color_blue">未支付</a>';	
					}else{
						showhtml1+=	'<span class="color_blue abate">已失效</span>';	
					}		
				}
		
				if(item.status==1)
					showhtml1+=	'<span class="color_blue">已支付</span>';
				if(item.status==2)
					showhtml1+=	'<span class="color_blue">医生已回复</span>';
				if(item.status==3)
					if(item.isCommented ==0){
						showhtml1+=	'<a  href="../service/evaluate-doctor.html?doctorid='+item.doctorid+'&serviceid='+item.id+'&type=3" class="color_blue">待评价</a>';
					
					}else{
						showhtml1+=	'<span href="javascript:;"  class="color_blue">已评价</span>';
					}
					
				if(item.status==4)
					showhtml1+=	'<span href="javascript:;"  class="color_blue">已评价</span>';
				if(item.status==5)
					showhtml1+=	'<span href="javascript:;"  class="color_blue">退款完成</span>';
				if(item.status==6)
				showhtml1+=	'<span href="javascript:;"  class="color_blue">退款中</span>';
				showhtml1+='</div>';
				showhtml1+='<div class="time">';
				showhtml1+=item.createtime;
				showhtml1+='<span>|</span>'+item.deptName;
				showhtml1+=	'</div><div class="text font3">';
				showhtml1+=item.questionbody;
				showhtml1+='</div>';
				if(item.avatar){
					showhtml1+=	'<img src="'+item.avatar+'" />';
				}else{
					showhtml1+=	"<img src='../../images/default-doctor.png'/>";
				}
				showhtml1+=	'</li>';
		}
	}else{
		showhtml1='<div class="prescription-consultationBox"><div><img src="../../images/cf1_03.png" /><p class="font3" style="color:#999">您暂时没有要评价的订单</p></div></div>';
	}
	$($(".servise-content .servise-list")[2]).html(showhtml1);
}
$(function() {
	$(".all-service li").click(function(){
		$(this).addClass("active").siblings().removeClass("active");
		$(".servise-list").removeClass("active").eq($(".all-service li").index(this)).addClass("active"); 
	});
	
	$(".servise-list li .name a").parent().parent().on('click',function(){
			location.href = $(".servise-list li .name a").attr("href");
	});
	
});
$(".html-loding").hide();